package ar.com.personalTravellers.services.impl;

import ar.com.personalTravellers.beans.Client;
import ar.com.personalTravellers.beans.Country;
import ar.com.personalTravellers.daos.ClientDAO;
import ar.com.personalTravellers.services.ClientService;
import com.angel.arquitectura.service.impl.GenericServiceImpl;
import org.apache.log4j.Logger;

import java.util.Collection;

public class ClientServiceImpl extends GenericServiceImpl implements ClientService {

    private static Logger LOGGER = Logger.getLogger(ClientServiceImpl.class);

    protected ClientDAO getClientDAO(){
        return (ClientDAO) super.getGenericDAO();
    }

    public Collection<Client> findAllByName(String clientName) {
        return this.getClientDAO().findAllByName(clientName);
    }

    public Collection<Client> findAllBySurName(String clientSurname) {
        return this.getClientDAO().findAllBySurName(clientSurname);
    }

    public Client findUniqueByNameAndSurname(String clientName, String clientSurname) {
        return this.getClientDAO().findUniqueByNameAndSurname(clientName, clientSurname);
    }

    public Collection<Client> findAllByCountry(Country country) {
        return this.getClientDAO().findAllByCountry(country);
    }

    public Client findUniqueByEmail(String email) {
        return this.getClientDAO().findUniqueByEmail(email);
    }

    public Client findUniqueByTelephone(String telephone) {
        return this.getClientDAO().findUniqueByTelephone(telephone);
    }

    public Client findUniqueOrNullByNameSurnameAndEmail(String clientName, String clientSurname, String email) {
        return this.getClientDAO().findUniqueOrNullByNameSurnameAndEmail(clientName, clientSurname, email);
    }

    public Boolean existByNameSurnameAndEmail(String clientName, String clientSurname, String email) {
        return this.findUniqueOrNullByNameSurnameAndEmail(clientName, clientSurname,email) != null;
    }
}